// 测试es6中的类的私有变量和私有方法
class MyClass {
  #privateField = 42;

  #privateMethod() {
    console.log("This is a private method");
  }

  publicMethod() {
    console.log(this.#privateField);
    this.#privateMethod();
  }

  showPrivateField() {
    this.#privateField = 100;
    console.log(this.#privateField);
  }

  // 测试类中的set和get方法
  set privateField(value) {
    console.log("sss")
    this.#privateField = value + 10;
  }
  get privateField() {
    console.log("ddd")
    return this.#privateField;
  }
  // 貌似没有效果

  testName = "testName";
  set testName(value) {
    console.log("ssssssssssss")
    this.testName = value;
  }
  get testName() {
    console.log("ddd")
    return this.testName;
  }
}

const myObj = new MyClass();

class MyClass2 {
  constructor() {
    this.testName = "testName";
  }

  set testName(value) {
    console.log("ssssssssssss");
    this._testName = value;
  }
  get testName() {
    console.log("ddd")
    return this._testName;
  }
}

const myClass2 = new MyClass2();
console.log(myClass2.testName)